package com.capgemini.fs.app.ekms.common;

public class CommonMethods {
	public static String formatDate(java.util.Date date) {
		String result = "";
		java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat(
				"yyyy-MM-dd");
		result = dateFormat.format(date);
		return result;
	}

	public static String getTimeInterval(long time) {
		time = time / 1000;
		long t = 0;
		if ((t = time / (365 * 24 * 3600)) > 0)
			return String.valueOf(t) + "years ago";
		else if ((t = time / (30 * 24 * 3600)) > 0)
			return String.valueOf(t) + "months ago";
		else if ((t = time / (7 * 24 * 3600)) > 0)
			return String.valueOf(t) + "weeks ago";
		else if ((t = time / (24 * 3600)) > 0)
			return String.valueOf(t) + "days ago";
		else if ((t = time / (3600)) > 0)
			return String.valueOf(t) + "hours ago";
		else if ((t = time / (60)) > 0)
			return String.valueOf(t) + "minutes ago";
		else
			return String.valueOf(time) + "seconds ago";
	}
}
